import { fetch, view, add, del, undel } from '@/services/resources';

const Model = {
  namespace: 'resources',
  state: {},
  effects: {
    *fetch({ payload, callback }, { call }) {
      const response = yield call(fetch, payload);
      if (callback) {
        callback(response);
      }
    },
    *view({ payload, callback }, { call }) {
      const response = yield call(view, payload);
      if (callback) {
        callback(response);
      }
    },
    *add({ payload, callback }, { call }) {
      const response = yield call(add, payload);
      if (callback) {
        callback(response);
      }
    },
    *undel({ payload, callback }, { call }) {
      const response = yield call(undel, payload);
      if (callback) {
        callback(response);
      }
    },
    *del({ payload, callback }, { call }) {
      const response = yield call(del, payload);
      if (callback) {
        callback(response);
      }
    },
  },
  reducers: {},
};
export default Model;
